package cn.edu.scau.cmi.dengyu.client;

import cn.edu.scau.cmi.dengyu.composite.consistent.China;
import cn.edu.scau.cmi.dengyu.composite.consistent.Composite;
import cn.edu.scau.cmi.dengyu.composite.consistent.USA;
import cn.edu.scau.cmi.dengyu.composite.consistent.UnitedNation;
import cn.edu.scau.cmi.dengyu.composite.consistent.WorldOrganization;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ClientUI extends Application{
	final static String[] experienceTypes = 
		{"实验一 单例模式", "实验一 多例模式", "实验二 简单工厂模式", "实验二 工厂模式",
				"实验二 抽象工厂模式", "实验三 对象适配器模式", "实验三 类适配器模式",
				"实验四 安全型组合模式", "实验四 一致型组合模式"};
	private static TextArea taDescription = new TextArea();
	
	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		GridPane pane0 = new GridPane();
		pane0.setAlignment(Pos.CENTER);
		pane0.setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
		pane0.setHgap(5.5);
		pane0.setVgap(5.5);


		Button bt0 = new Button(experienceTypes[0]);
		bt0.setOnAction(e -> {
			try {
				setScene(0);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt1 = new Button(experienceTypes[1]);
		bt1.setOnAction(e -> {
			try {
				setScene(1);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt2 = new Button(experienceTypes[2]);
		bt2.setOnAction(e -> {
			try {
				setScene(2);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt3 = new Button(experienceTypes[3]);
		bt3.setOnAction(e -> {
			try {
				setScene(3);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt4 = new Button(experienceTypes[4]);
		bt4.setOnAction(e -> {
			try {
				setScene(4);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt5 = new Button(experienceTypes[5]);
		bt5.setOnAction(e -> {
			try {
				setScene(5);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt6 = new Button(experienceTypes[6]);
		bt6.setOnAction(e -> {
			try {
				setScene(6);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt7 = new Button(experienceTypes[7]);
		bt7.setOnAction(e -> {
			try {
				setScene(7);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		Button bt8 = new Button(experienceTypes[8]);
		bt8.setOnAction(e -> {
			try {
				setScene(8);
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});

		taDescription.setWrapText(true);
		taDescription.setEditable(false);
		pane0.add(new Label("姓名：邓昱"), 0, 0);
		pane0.add(new Label("学号：201627010204"), 1, 0);
		pane0.add(new Label("请选择实验:"), 0, 1);
		pane0.add(bt0, 0, 2);
		GridPane.setHalignment(bt0, HPos.LEFT);
		pane0.add(bt1, 0, 3);
		GridPane.setHalignment(bt1, HPos.LEFT);
		pane0.add(bt2, 0, 4);
		GridPane.setHalignment(bt2, HPos.LEFT);
		pane0.add(bt3, 0, 5);
		GridPane.setHalignment(bt3, HPos.LEFT);
		pane0.add(bt4, 0, 6);
		GridPane.setHalignment(bt4, HPos.LEFT);
		pane0.add(bt5, 0, 7);
		GridPane.setHalignment(bt5, HPos.LEFT);
		pane0.add(bt6, 0, 8);
		GridPane.setHalignment(bt6, HPos.LEFT);
		pane0.add(bt7, 0, 9);
		GridPane.setHalignment(bt7, HPos.LEFT);
		pane0.add(bt8, 0, 10);
		GridPane.setHalignment(bt8, HPos.LEFT);
		
		HBox hBox = new HBox();
		Image image = new Image("cn/edu/scau/cmi/dengyu/client/pic.jpg");
		ImageView imageView = new ImageView(image);
		
		imageView.setFitHeight(500);
		imageView.setFitWidth(500); 
		imageView.setPreserveRatio(true); 
		hBox.getChildren().add(imageView);
		hBox.getChildren().add(pane0);

		Scene scene = new Scene(hBox);
		primaryStage.setTitle("综合性实验汇总");
		primaryStage.setScene(scene);
		primaryStage.show();

	}

	public static void main(String[] args) {
		Application.launch(args);
	}
	
	public static void setScene(int index) throws Exception {
		switch (index){
		case 0: new SingletonPane().showWindow(); break;
		case 1: new MultipletonPane().showWindow(); break;
		case 2: new SimpleFactoryMethodClient().showWindow(); break;
		case 3: new FactoryMethodClient().showWindow(); break;
		case 4: new AbstractFactoryMethodClient().showWindow(); break;
		case 5: new AdapterOfObjectClient().showWindow(); break;
		case 6: new AdapterOfClassClient().showWindow(); break;
		case 7: new CompositeSafeClient().showWindow(); break;
		case 8: new CompositeConsistentClient().showWindow(); break;

		}
	}

	
}
